<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.12.4.min.js"></script>
</head>
<body>
<h2>登录</h2>
<form id="f1">
    Name:<input type="text" name="userName"/>
    <input type="button" value="登录">
</form>
<script>
    $(function(){
        $(':button').on('click', function(){
            $.ajax({
                url: 'user/login',
                type: 'get',
                data: $('#f1').serialize(),
                success: function(result) {
                    if(result.code == 10000) {
                        alert(result.message);
                    }else if(result.code == 200) {
                        location.href = "index.html";
                    }
                }
            });
        });
    });
</script>
</body>
</html>